<div class="sidebar">
    <div class="logo">
        <h2><?php echo SITE_NAME; ?></h2>
    </div>
    <nav>
        <ul>
            <li>
                <a href="index.php" class="<?php echo $current_page == 'index' ? 'active' : ''; ?>">
                    <i class="fas fa-tachometer-alt"></i>
                    <span>控制台</span>
                </a>
            </li>

            <?php if ($_SESSION['role'] == 1): ?>
            <li>
                <a href="admin_users.php" class="<?php echo $current_page == 'admin_users' ? 'active' : ''; ?>">
                    <i class="fas fa-user-shield"></i>
                    <span>管理员管理</span>
                </a>
            </li>
            <?php endif; ?>

            <li>
                <a href="coaches.php" class="<?php echo $current_page == 'coaches' ? 'active' : ''; ?>">
                    <i class="fas fa-user-tie"></i>
                    <span>教练管理</span>
                </a>
            </li>

            <li>
                <a href="users.php" class="<?php echo $current_page == 'users' ? 'active' : ''; ?>">
                    <i class="fas fa-users"></i>
                    <span>用户管理</span>
                </a>
            </li>

            <li>
                <a href="banners.php" class="<?php echo $current_page == 'banners' ? 'active' : ''; ?>">
                    <i class="fas fa-images"></i>
                    <span>轮播图管理</span>
                </a>
            </li>

            <li>
                <a href="fitness_guides.php" class="<?php echo $current_page == 'fitness_guides' ? 'active' : ''; ?>">
                    <i class="fas fa-book"></i>
                    <span>健身指南管理</span>
                </a>
            </li>

            <li class="has-submenu <?php echo in_array($current_page, ['posts', 'comments']) ? 'active' : ''; ?>">
                <a href="javascript:void(0)" class="menu-toggle">
                    <i class="fas fa-comments"></i>
                    <span>论坛管理</span>
                    <i class="fas fa-chevron-down submenu-icon"></i>
                </a>
                <ul class="submenu">
                    <li><a href="posts.php" class="<?php echo $current_page == 'posts' ? 'active' : ''; ?>">帖子管理</a></li>
                    <li><a href="comments.php" class="<?php echo $current_page == 'comments' ? 'active' : ''; ?>">评论管理</a></li>
                </ul>
            </li>

            <li class="has-submenu <?php echo in_array($current_page, ['courses', 'course_bookings']) ? 'active' : ''; ?>">
                <a href="javascript:void(0)" class="menu-toggle">
                    <i class="fas fa-calendar-alt"></i>
                    <span>团课管理</span>
                    <i class="fas fa-chevron-down submenu-icon"></i>
                </a>
                <ul class="submenu">
                    <li><a href="courses.php" class="<?php echo $current_page == 'courses' ? 'active' : ''; ?>">团课课程管理</a></li>
                    <li><a href="course_bookings.php" class="<?php echo $current_page == 'course_bookings' ? 'active' : ''; ?>">预约记录管理</a></li>
                </ul>
            </li>

            <li class="has-submenu <?php echo in_array($current_page, ['private_courses', 'private_bookings']) ? 'active' : ''; ?>">
                <a href="javascript:void(0)" class="menu-toggle">
                    <i class="fas fa-user-clock"></i>
                    <span>私教预约管理</span>
                    <i class="fas fa-chevron-down submenu-icon"></i>
                </a>
                <ul class="submenu">
                    <li><a href="private_courses.php" class="<?php echo $current_page == 'private_courses' ? 'active' : ''; ?>">教练排班管理</a></li>
                    <li><a href="private_bookings.php" class="<?php echo $current_page == 'private_bookings' ? 'active' : ''; ?>">预约记录管理</a></li>
                </ul>
            </li>
            <li>
                <a href="evaluations.php" class="<?php echo $current_page == 'evaluations' ? 'active' : ''; ?>">
                    <i class="fas fa-star-half-alt"></i>
                    <span>评价管理</span>
                </a>
            </li>

            <li>
                <a href="feedback.php" class="<?php echo $current_page == 'feedback' ? 'active' : ''; ?>">
                    <i class="fas fa-comment-dots"></i>
                    <span>意见反馈</span>
                </a>
            </li>

            <li>
                <a href="announcements.php" class="<?php echo $current_page == 'announcements' ? 'active' : ''; ?>">
                    <i class="fas fa-bullhorn"></i>
                    <span>公告管理</span>
                </a>
            </li>
        </ul>
    </nav>

    <style>
    .sidebar {
        width: 250px;
        background: #2c3e50;
        color: #fff;
        height: 100vh;
        position: fixed;
        left: 0;
        top: 0;
    }

    .sidebar .logo {
        padding: 20px;
        text-align: center;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }

    .sidebar nav ul {
        list-style: none;
        padding: 0;
        margin: 0;
    }

    .sidebar nav ul li {
        position: relative;
    }

    .sidebar nav ul li a {
        display: flex;
        align-items: center;
        padding: 12px 20px;
        color: #fff;
        text-decoration: none;
        transition: all 0.3s;
    }

    .sidebar nav ul li a:hover {
        background: rgba(255,255,255,0.1);
    }

    .sidebar nav ul li a.active {
        background: #3498db;
    }

    .sidebar nav ul li a i {
        margin-right: 10px;
        width: 20px;
        text-align: center;
    }

    .submenu-icon {
        margin-left: auto;
        transition: transform 0.3s;
    }

    .has-submenu.active > a .submenu-icon {
        transform: rotate(180deg);
    }

    .submenu {
        display: none;
        background: rgba(0,0,0,0.1);
    }

    .has-submenu.active > .submenu {
        display: block;
    }

    .submenu li a {
        padding-left: 50px;
    }

    .submenu li a:hover {
        background: rgba(255,255,255,0.05);
    }

    .submenu li a.active {
        background: rgba(52,152,219,0.5);
    }
    </style>

    <script>
    document.addEventListener('DOMContentLoaded', function() {
        // 获取所有带有子菜单的菜单项
        const menuItems = document.querySelectorAll('.has-submenu');
        
        // 为每个菜单项添加点击事件
        menuItems.forEach(item => {
            const toggle = item.querySelector('.menu-toggle');
            toggle.addEventListener('click', function(e) {
                e.preventDefault();
                
                // 切换当前菜单的展开状态
                item.classList.toggle('active');
                
                // 关闭其他展开的子菜单
                menuItems.forEach(otherItem => {
                    if (otherItem !== item && otherItem.classList.contains('active')) {
                        otherItem.classList.remove('active');
                    }
                });
            });
        });

        // 如果当前页面在子菜单中，自动展开父菜单
        const currentMenuItem = document.querySelector('.submenu a.active');
        if (currentMenuItem) {
            const parentMenu = currentMenuItem.closest('.has-submenu');
            if (parentMenu) {
                parentMenu.classList.add('active');
            }
        }
    });
    </script>
</div> 